package com.example.botany_api.service;

import com.example.botany_api.bean.User;
import com.example.botany_api.mapper.UserMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 漫画忧作
 * @Date 2022/9/24 10:51
 * @Version 1.0
 */
@Service
public class UserService {
    @Autowired
    UserMapper userMapper;


    public User register(User user) {
        return userMapper.register(user);
    }

    //    分页
    public List getUserList(String name, String address, int current, int size) {
        return userMapper.getUserList(name, address, current, size);
    }

    //    总数
    public int getUserListTotal(String name, String address) {
        return userMapper.getUserListTotal(name, address);
    }

    //    删除用户
    public int dl_User(int id) {
        return userMapper.dl_User(id);
    }

    //     禁用或解禁用户
    public int di_User(int id, int state) {
        return userMapper.di_User(id, state);
    }

    //    添加用户
    public int add_User(User user) {
        return userMapper.add_User(user);
    }
    //    修改用户
    public int up_User(User user) {
        return userMapper.up_User(user);
    }
    //    修改管理员密码
    public int up_adminPass(User user) {
        return userMapper.up_adminPass(user);
    }

//    图表接口

    public int waterChartCollect() {
        return userMapper.waterChartCollect();
    }
    public int waterChartViews() {
        return userMapper.waterChartViews();
    }

    public List topCount() {
        List list=new ArrayList();
        list.add(userMapper.galleryCount());
        list.add(userMapper.meatyCount());
        list.add(userMapper.curingCount());
        list.add(userMapper.informationCount());

        return list;
    }
    public List topChartViews(){
        return userMapper.topChartViews();
    }
    public List topChartCollect(){
        return userMapper.topChartCollect();
    }
}
